import { generateUUID } from '@/utils'
import { localeProps } from '@/components/FormCreate/src/utils'


export interface DataTableProp{
  modelValue:any,
  apiAddress:string
}



/**
 * 字段忽略类型
 */
export enum FieldIgnoreType {
  DataTable = "DataTable",
  SubForm = "subForm",
  Left = "LEFT",
  Right = "RIGHT"
}

export enum FormCreateVxeControlTypeMapping{

}

/**
 * 通用选择器规则 hook
 *
 * @param option 规则配置
 */
export const UseVxeTableRuleRule = (option: any) => {
  const label = option.label
  const name = option.name

  const rules =[ {
    type: 'input',
    field: 'apiAddress',
    title: '接口地址',
    props: {
      placeholder: '请输入接口地址',
      apiAddress: 'http://113.44.67.181:8085/formdata/formlist'
    }
  }]

  return {
    icon: option.icon,
    label,
    name,
    rule() {
      return {
        type: name,
        id: generateUUID(),
        field: generateUUID(),
        title: label,
        info: '',
        value: null,
        $required: false
      }
    },
    props(_, { t }) {
      if (!option.props) {
        option.props = []
      }
      return localeProps(t, name + '.props', [...option.props, ...rules])
    }
  }
}
